package com.dataaccess.dataaccess.web.service;

import cn.hutool.json.JSONObject;
import com.dataaccess.dataaccess.common.base.BaseService;
import com.dataaccess.dataaccess.support.model.RespEntity;
import com.dataaccess.dataaccess.support.utils.requestutil.HttpRequestUtil;
import org.springframework.stereotype.Service;

@Service
public class ChkPointPostDataService extends BaseService {
    public RespEntity JsonDevice(JSONObject jsonParam) throws Exception {
        //处理支持form-data和json两种方式
        jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
        //解析数据开始-------------------------------------------------------------------------------------------------------
        String DataType = jsonParam.getStr("DataType");//设备ID
        String  name= jsonParam.getStr("FTypeBH");//设备名称
        String  devType   = jsonParam.getStr("DevType");//设备类型0
        String     businessId  = jsonParam.getStr("ComID");//公司ID
        String    businessName  = jsonParam.getStr("ComName");//公司名称
        String      position  = jsonParam.getStr("DevPos");//地址
        String MinValue  = jsonParam.getStr("MinValue");//最大
        String MaxValue = jsonParam.getStr("MaxValue");//最小
        String AlarmTel = jsonParam.getStr("alarmPhone");//报警电话
        String DevType = null;
        if (devType.equals("1")) {
            DevType = "01";
        } else if (devType.equals("2")) {
            DevType = "02";
        } else if (devType.equals("3")) {
            DevType = "03";
        } else if (devType.equals("4")) {
            DevType = "04";
        } else if (devType.equals("5")) {
            DevType = "05";
        }
        JSONObject jsonDevice=new JSONObject();

//        jsonDevice.put("number",number);
        jsonDevice.put("name",name);
        jsonDevice.put("DevType",DevType);
        jsonDevice.put("businessId",businessId);
        jsonDevice.put("businessName",businessName);
        jsonDevice.put("position",position);
        jsonDevice.put("MinValue",MinValue);
        jsonDevice.put("MaxValue",MaxValue);
        jsonDevice.put("AlarmTel",AlarmTel);
        return fireFightingiotTwo(jsonDevice, "devicesynchronization", "devicetwoSynchronization", "DevicetwoSynchronization", "token");

    }
}
